package com.os.meituan.common;


import org.springframework.context.annotation.Bean;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

//@EnableSwagger2
//@Configuration
//@Profile({"dev", "local"}) // 在指定环境下才启用
public class Swagger2Config {

    // https://blog.csdn.net/weixin_36001063/article/details/83659463  增强配置请看这里

    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.os"))
//                .apis(RequestHandlerSelectors.withMethodAnnotation(Api.class))  // 可以只扫描特定的注解
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("api文档")
                .description("我是description")
                .termsOfServiceUrl("https://www.baidu.com")
                .version("1.0")
                .build();
    }
}
